/*
 * @Descripttion:
 * @version:
 * @Author: lixx
 * @Date: 2025-07-08 17:03:23
 * @LastEditors: lixx
 * @LastEditTime: 2025-07-08 17:48:47
 */
import router from './router'
import { createVNode, render } from 'vue'
import LoadingBar from './components/LoadingBar.vue'

const VNode = createVNode(LoadingBar)

render(VNode, document.body)

const whiteList = ['/']
router.beforeEach((to, from, next) => {
  console.log('to+++', to)
  console.log('1111', whiteList.includes(to.path))
  if (whiteList.includes(to.path)) {
    next()
  } else if (!localStorage.getItem('token')) {
    next('/')
  } else {
    next()
  }
  VNode.component?.exposed?.startLoading()
})

router.afterEach(() => {
  VNode.component?.exposed?.endLoading()
})
